package com.distribute.application.manage.coupons;

import java.util.*;
import java.io.File;

import com.distribute.framework.core.web.helper.Utils;
import com.distribute.framework.core.lang.*;
import com.distribute.framework.core.web.node.Export;
import com.distribute.framework.core.lang.Protocol.BeanFormat;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.web.util.*;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;

import com.distribute.framework.model.*;
import com.distribute.application.manage.*;
/************CTRL_CODE_INPORT************/
/************CTRL_CODE_INPORT************/

/**
 * 线下优惠券的Controller
 * @author 飞啊飘啊
 */
@SuppressWarnings({"unchecked","rawtypes"})
@flag("OfflineCoupon")
@RestController
@Component(value="manage.coupons.offlinecouponController")
public class OfflinecouponController{
	
	@flag("stuct")
	@RequestMapping("/manage/coupons/offlinecoupon.list.do")
  	public Protocol list() {
  		try{
  			Protocol protocol = Protocol.create(true,null);
  			setFormDataInfo(protocol,null,null);
  			//处理页面的视图数据，比如显示哪些列，自定义显示列等
			ActionHelper.doPageViewFields(OfflineCoupon.class);
  			Map<String,Object> params = setDefaultSort(ActionHelper.getQueryFormParams(OfflineCoupon.class));
			protocol.set("PARAMS",ActionHelper.getQueryFormParams(OfflineCoupon.class));
			protocol.set("fields", Utils.getRequest("fields"));
			Integer iPage = Utils.getInteger("page", 0);
			Integer iSize = Utils.getInteger("size",16);
			params.put("merchant",LoginHelper.getLogin().getId());
			/************CTRL_BEFORE_LIST************/
			/************CTRL_BEFORE_LIST************/
			Page page = OfflineCoupon.page(iPage,iSize,params);//调用获取分页
	    	protocol.setPage(page,new BeanFormat<OfflineCoupon>(){
				public Map format(OfflineCoupon t) {
					return t.toJSON();
				}
			});
			/************CTRL_AFTER_LIST************/
			/************CTRL_AFTER_LIST************/
			return protocol;
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
  	}
  	@RequestMapping("/manage/coupons/offlinecoupon.export.do")
  	public Protocol export(HttpServletResponse response) {
  		try{
  			Protocol protocol = Protocol.create(true,null);
  			setFormDataInfo(protocol,null,null);
  			//处理页面的视图数据，比如显示哪些列，自定义显示列等
			ActionHelper.doPageViewFields(OfflineCoupon.class);
  			Map<String,Object> params = setDefaultSort(ActionHelper.getQueryFormParams(OfflineCoupon.class));
  			params.put("idIn", Utils.getString("ids"));
			Integer iPage = Utils.getInteger("page", 0);
			Integer iSize = Utils.getInteger("size",16);
			params.put("merchant",LoginHelper.getLogin().getId());
			/************CTRL_BEFORE_EXPORT************/
			/************CTRL_BEFORE_EXPORT************/
			final Map<String, Object> finalParams = params;
			//调用lazy3q.jar中的导出功能
			//参数说明：(这次导出多少条数据，到数据库查的时候一次查多少条，当前所在第几页,处理器，对应的模型类,要导出哪些字段)
			Utils.export(OfflineCoupon.count(params).intValue(), 100, 0 , new Export(){//new Export这个类，他会根据参数分次查询，边查边写，目的只有一个，就是为了避免把大量的数据放在内存中
				@Override //重载实现Export的getPage方法，Export会分多次调用这个方法
				public Page getPage(Integer page, int size) {//这时的page和size是Export转化过后的当前页，每页查询数					
					return OfflineCoupon.getOfflineCouponPage(page, size, finalParams);
				}
			}, OfflineCoupon.class, Utils.getString("fields").split(","));
			/************CTRL_AFTER_EXPORT************/
			/************CTRL_AFTER_EXPORT************/
			return null;
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
  	}
  	
  	
  	@flag("stuct")
  	@RequestMapping("/manage/coupons/offlinecoupon.get.do")
  	public Protocol get() {
  		try{
  			Protocol protocol = Protocol.create(true,null).set("offlineCoupon",new HashMap());
  			OfflineCoupon offlineCoupon = Utils.getObject("", OfflineCoupon.class);
  			if(offlineCoupon!=null){
				protocol.set("offlineCoupon",offlineCoupon.toJSON());
			}
			Long id=Utils.or(Utils.getLong("id"),Utils.getLong("key"));
			String edittype = Utils.getString("edittype");
			if(id==null){
				setFormDataInfo(protocol,edittype,null);
				return protocol.reset(false,null,"args-id-null");
			}			
			offlineCoupon=OfflineCoupon.where.id(id).get();
			if(offlineCoupon==null){
				return protocol.reset(false,"数据不存在","data-not-exist");
			}
			setFormDataInfo(protocol,edittype,offlineCoupon);
			if(offlineCoupon.getMerchant().longValue()!=LoginHelper.getLogin().getId().longValue()){
				protocol.reset(false,"没有权限访问数据","host-no-mate");
				offlineCoupon=null;
			}
			protocol.set("offlineCoupon",offlineCoupon.toJSON());
			/************CTRL_CODE_GET************/
			/************CTRL_CODE_GET************/
			return protocol;
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
  	}
  	
  	
  	
  	@limitVal(2)//查看权限
  	@RequestMapping("/manage/coupons/offlinecoupon.insert.do")
  	public Protocol insert() {
  		try{
			final String requestToken = Utils.getString("offlineCouponToken");
			final Date lastToken = Utils.getSession(requestToken);
			if(lastToken==null || (new Date().getTime()-lastToken.getTime())>10000){
				if(requestToken!=null)Utils.setSession(requestToken,new Date());//放入Token时间戳	
				OfflineCoupon.execute(new Function(){
					public <T> T execute(Object... arg0){
						/************CTRL_BEFOR_INSERT************/
						/************CTRL_BEFOR_INSERT************/
						OfflineCoupon offlineCoupon = Utils.getObject("offlineCoupon", OfflineCoupon.class);
						//批量插入处理
						String vValue = ""+(offlineCoupon.getId()==null?"":offlineCoupon.getId());
						String sArray[]={""+vValue};
						if(vValue.startsWith("[*]")){
							vValue=vValue.replace("[*]","");
							sArray=vValue.split("[\\s|\u3000|\\u00a0|,]+");		
						}
						for(String sItem:sArray){
							if(!Utils.empty(sItem))
							offlineCoupon.setId(Long.valueOf(sItem));
							//设置默认值
							setDefaultValue(offlineCoupon,"insert");
							offlineCoupon.setMerchant(LoginHelper.getLogin().getId());
								/************CTRL_BEFORE_ADD************/
								/************CTRL_BEFORE_ADD************/
							OfflineCoupon.saveOfflineCoupon(offlineCoupon);			
								/************CTRL_AFTER_ADD************/
								/************CTRL_AFTER_ADD************/
						}
						//记录操作日志
						LoggerHelper.writeLog(OfflineCoupon.class,"add","添加了[线下优惠券]["+offlineCoupon.getId()+"]",LoginHelper.getUserId(), offlineCoupon,offlineCoupon.getId());
						return null;
					}
				});
				
			}else{
				throw new DefineException("repeat-submit-error","对不起，请勿重复提交"+(10-((new Date().getTime()-lastToken.getTime())/1000))+"秒后再试");
			}
			/************CTRL_AFTER_INSERT************/
			/************CTRL_AFTER_INSERT************/
			return Protocol.create(true,"添加[线下优惠券]数据成功");
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
  	}
  	
  	
  	
  	@limitVal(4)//修改权限
  	@RequestMapping("/manage/coupons/offlinecoupon.update.do")
  	public Protocol update() {
  		try{
			final String requestToken = Utils.getString("offlineCouponToken");
			final Date lastToken = Utils.getSession(requestToken);
			if(lastToken==null || (new Date().getTime()-lastToken.getTime())>10000){
				if(requestToken!=null)Utils.setSession(requestToken,new Date());//放入Token时间戳	
				OfflineCoupon.execute(new Function(){
					public <T> T execute(Object... arg0){
						/************CTRL_BEFOR_UPDATE************/
						/************CTRL_BEFOR_UPDATE************/
						OfflineCoupon offlineCoupon = Utils.getObject("offlineCoupon", OfflineCoupon.class);
						OfflineCoupon oldOfflineCoupon = null;
						String PARAMS = Utils.getString("PARAMS");
						String ids=Utils.getString("ids");
						if(!Utils.empty(PARAMS)){//根据查询条件批量更新
							Map params = Utils.eval(PARAMS);
							params.put("confirm", 1);
							params.put("definex","1=1");
							offlineCoupon.setMerchant(LoginHelper.getLogin().getId());
							
							OfflineCoupon.updateOfflineCouponByConfirm(ActionHelper.getSetValuesFromModel(offlineCoupon), params);
							LoggerHelper.writeLog(OfflineCoupon.class, "update", 
										"批量修改了[线下优惠券]",
										LoginHelper.getUserId(),LoggerHelper.getUpdateDescription(null,offlineCoupon,false)
										,null);
							/************CTRL_UPDATE_BY_PARAMS************/
							/************CTRL_UPDATE_BY_PARAMS************/
						}else if(!Utils.empty(ids)){//根据ids批量更新
							Map params = new HashMap();
							params.put("idIn",ids);
							params.put("confirm", 1);
							params.put("definex","1=1");
							OfflineCoupon.updateOfflineCouponByConfirm(ActionHelper.getSetValuesFromModel(offlineCoupon), params);
							LoggerHelper.writeLog(OfflineCoupon.class, "update", 
										"批量修改了[线下优惠券]",
										LoginHelper.getUserId(),LoggerHelper.getUpdateDescription(null,offlineCoupon,false)
										,null);
							/************CTRL_UPDATE_BY_IDS************/
							/************CTRL_UPDATE_BY_IDS************/
						}else{
							if(Utils.empty(Utils.getString("all"))){//修改对象非空的字段
								oldOfflineCoupon=OfflineCoupon.where.id(offlineCoupon.getId()).get();
								if(oldOfflineCoupon==null){
									throw new DefineException("对不起，你没有权限修改当前数据");
								}
								
								OfflineCoupon.updateOfflineCoupon$NotNull(offlineCoupon);
								LoggerHelper.writeLog(OfflineCoupon.class, "update", 
										"修改了[线下优惠券]["+oldOfflineCoupon.getId()+"]",
										LoginHelper.getUserId(),LoggerHelper.getUpdateDescription(oldOfflineCoupon, offlineCoupon,false)
										,offlineCoupon.getId());
								/************CTRL_UPDATE_NOT_NULL************/
								/************CTRL_UPDATE_NOT_NULL************/
							}else{//修改对象全部字段
								oldOfflineCoupon=OfflineCoupon.where.id(offlineCoupon.getId()).get();
								if(oldOfflineCoupon==null){
									throw new DefineException("对不起，你没有权限修改当前数据");
								}
								//设置默认值
								offlineCoupon.setUpdateTime(oldOfflineCoupon.getUpdateTime());	
								offlineCoupon.setAddTime(oldOfflineCoupon.getAddTime());	
								//设置默认值
								setDefaultValue(offlineCoupon,"update");
								
								//从oldOfflineCoupon同步offlineCoupon未set过的值
								offlineCoupon.mergeSet(oldOfflineCoupon);
										
								OfflineCoupon.updateOfflineCoupon(offlineCoupon);
								LoggerHelper.writeLog(OfflineCoupon.class, "update", 
										"修改了[线下优惠券]["+oldOfflineCoupon.getId()+"]",
										LoginHelper.getUserId(),LoggerHelper.getUpdateDescription(oldOfflineCoupon, offlineCoupon,true)
										,offlineCoupon.getId());
								/************CTRL_UPDATE_ALL************/
								/************CTRL_UPDATE_ALL************/
							}
						}
						/************CTRL_CODE_UPDATE************/
						/************CTRL_CODE_UPDATE************/
						return null;
					}
				});
				
			}else{
				throw new DefineException("repeat-submit-error","对不起，请勿重复提交"+(10-((new Date().getTime()-lastToken.getTime())/1000))+"秒后再试");
			}
			/************CTRL_AFTER_UPDATE************/
			/************CTRL_AFTER_UPDATE************/
			return Protocol.create(true,"修改[线下优惠券]数据成功");
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
  	}
  	
  	@limitVal(8)//删除权限
  	@RequestMapping("/manage/coupons/offlinecoupon.delete.do")
  	public Protocol delete() {
  		try{
			OfflineCoupon.execute(new Function(){
				public <T> T execute(Object... arg0){
					Long pid=Utils.getLong("id");
					Long[] ids=new Long[]{pid};
					String strIds=Utils.getString( "ids");
					if(!Utils.empty(strIds) && !strIds.trim().equals("")){//批量删除
						String[] array = strIds.split(",");
						ids=new Long[array.length];
						for(int i=0;i<array.length;i++)
							ids[i]=Long.valueOf(array[i]);
					}
					if(ids.length==0){
						throw new DefineException("args-id-null","参数错误");
					}
					for(Long id:ids){
						OfflineCoupon offlineCoupon = null;
						offlineCoupon=OfflineCoupon.where.id(id).get();
						if(offlineCoupon==null){
							throw new DefineException("对不起，你没有权限修改当前数据");
						}
						OfflineCoupon.delete(id);						
						if(offlineCoupon!=null)//记录操作日志
							LoggerHelper.writeLog(OfflineCoupon.class,"del","删除了[线下优惠券]["+offlineCoupon.getId()+"]",LoginHelper.getUserId(), offlineCoupon);
						/************CTRL_CODE_DEL************/
						/************CTRL_CODE_DEL************/
					}
					return null;
				}
			});
			return Protocol.create(true,"删除操作成功");
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
  	}

	@RequestMapping("/manage/coupons/offlinecoupon.query.do")
	public Protocol query(){
		try{
			Map<String,Object> params = setDefaultSort(ActionHelper.getQueryFormParams(OfflineCoupon.class));
			params.put("merchant",LoginHelper.getLogin().getId());
			
			String strTerm=Utils.getString("value");//智能搜索时的参数，一般都是主键后面那个字段
			if(!Utils.empty(strTerm)){
				if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
					params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
				else//按标识查询，模糊查询请带%
				{
					String strDefinex = "";
					strDefinex="(2=1 "+strDefinex+")";
					params.put("definex",strDefinex);
				}
			}
			
			Integer iSize = Utils.getInteger("size",10);
			/************CTRL_CODE_QUERY************/
			/************CTRL_CODE_QUERY************/
			
			List<OfflineCoupon> list = OfflineCoupon.page(0,iSize,params).getResult();
			
			Boolean bObject=Utils.getBoolean("object",false);//是否需要整个数据对象
			List<Map> result = new java.util.ArrayList();
			for(OfflineCoupon offlineCoupon:list){
				Map map = new HashMap();
				map.put("key",offlineCoupon.getId().toString());
				map.put("value", Utils.js(offlineCoupon.getKeyValue()));
				if(bObject==true){
					map.put("object",offlineCoupon);
				}
				result.add(map);
			}
			/************CTRL_AFTER_QUERY************/
			/************CTRL_AFTER_QUERY************/
			
			return Protocol.create().setList(result);
		}catch(DefineException e){
			return Protocol.create(false, e.getMessage(), e.getCode());
		}catch(Exception e){		
			e.printStackTrace();
			LoggerHelper.writeError(e);
			return Protocol.create(false,Utils.or(Utils.config("exception.message"), "系统繁忙，请稍后再试"),"exception");
		}
	}
	/************CTRL_DEFINE_CODE************/
	/************CTRL_DEFINE_CODE************/
  	
  	/**获取子项列表**/
	public static Map getItems(){
		Map map = new HashMap();
		/************CTRL_DEFINE_ITEMS************/
		/************CTRL_DEFINE_ITEMS************/
		return map;
	}
  	
  	/**
	* 设置排序
	**/
  	private Map<String,Object> setDefaultSort(Map<String, Object> params) {
		String strAsc=OfflineCoupon.C.get(Utils.forMat(Utils.getString("asc")));//升序字段
		params.put("asc", strAsc);//放入查询条件
		String strDesc=OfflineCoupon.C.get(Utils.forMat(Utils.getString("desc")));//降序字段
		params.put("desc",strDesc);//放入查询条件 
		if(Utils.empty(strAsc) && Utils.empty(strDesc))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		return params;
	}
  	/**
	* 设置默认值
	**/
	public void setDefaultValue(OfflineCoupon offlineCoupon,String type){
		if(type.equals("insert")){//添加时			
			if(offlineCoupon.getReceivingSituation()==null)
				offlineCoupon.setReceivingSituation((short)1);
			if(offlineCoupon.getUpdateTime()==null)
				offlineCoupon.setUpdateTime(new Date());
			if(offlineCoupon.getAddTime()==null)
				offlineCoupon.setAddTime(new Date());
			if(offlineCoupon.getStatus()==null)
				offlineCoupon.setStatus((short)0);
		}else if(type.equals("update")){//编辑时
			offlineCoupon.setUpdateTime(new Date());
		}
	}
	/**
	* 设置表单信息
	**/
	public void setFormDataInfo(Protocol protocol,String edittype,OfflineCoupon offlineCoupon){
		Map model = new HashMap();
		model.put("name","offlineCoupon");
		model.put("caption","线下优惠券");
		model.put("type","");
		model.put("icon","icon-zijinmingxi");
		model.put("PK","id");
		model.put("add",true);
		model.put("update",true);
		model.put("details",true);
		List propertys = new ArrayList();
		List submits = new ArrayList();
		model.put("propertys", propertys);
		model.put("submits", submits);	
		protocol.set("model", model);
		if(Utils.empty(edittype)){
		propertys.add(Utils.add("name","receivingSituation").add("cell","attr").add("caption","领取情况").add("input","select").add("primary",false).add("length",2).add("options",new Object[]{Utils.add("text","未领取").add("value","1"),Utils.add("text","已领取").add("value","2")}));
		propertys.add(Utils.add("name","status").add("cell","coner").add("caption","状　　态").add("input","select").add("primary",false).add("length",2).add("options",new Object[]{Utils.add("text","待扫码").add("value","0"),Utils.add("text","已领取").add("value","1")}));
		}
		else{
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","commodity").add("caption","适用商品").add("input","query").add("primary",false).add("length",8).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).add("relate","Commodity"));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","discount").add("caption","折　　扣").add("input","menoy").add("primary",false).add("length",8).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","termValidity").add("caption","有 效 期").add("input","datetime").add("primary",false).add("length",19).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","receiveCode").add("caption","领 取 码").add("input","text").add("primary",false).add("length",32).add("notNull",false).add("unique",true).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","qrCode").add("caption","二 维 码").add("input","image").add("primary",false).add("length",512).add("notNull",false).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","receivingSituation").add("caption","领取情况").add("input","select").add("primary",false).add("length",2).add("notNull",false).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).add("options",new Object[]{Utils.add("text","未领取").add("value","1"),Utils.add("text","已领取").add("value","2")}));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"none":"none")).equals("none")){
				propertys.add(Utils.add("name","updateTime").add("caption","修改时间").add("input","datetime").add("primary",false).add("length",19).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"none":"none")));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"none":"none")).equals("none")){
				propertys.add(Utils.add("name","addTime").add("caption","添加时间").add("input","datetime").add("primary",false).add("length",19).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"none":"none")));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"none":"editable")).equals("none")){
				propertys.add(Utils.add("name","status").add("caption","状　　态").add("input","select").add("primary",false).add("length",2).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"none":"editable")).add("options",new Object[]{Utils.add("text","待扫码").add("value","0"),Utils.add("text","已领取").add("value","1")}));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","merchant").add("caption","所属品牌").add("input","query").add("primary",false).add("length",8).add("notNull",true).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).add("relate","Merchant"));
			}
			if(!(edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")).equals("none")){
				propertys.add(Utils.add("name","usageRule").add("caption","使用规则").add("input","textarea").add("primary",false).add("length",225).add("notNull",false).add("unique",false).add("editable",edittype.equals("details")?"readonly":(edittype.equals("insert")?"editable":"editable")));
			}
			submits.add(Utils.add("name","submiter").add("value","完成").add("title","完成").add("icon","icon-weibiaoti8"));
		}
	}
  
}